package com.sherlocky.resource.common;

import java.util.Arrays;
import java.util.List;

public class ResourceContants {
	public final static List<String> RESOURCE_SUFFIX_WORD = Arrays.asList("doc","docx");
	public final static List<String> RESOURCE_SUFFIX_PPT = Arrays.asList("ppt","pptx");
	public final static List<String> RESOURCE_SUFFIX_EXCEL = Arrays.asList("xls","xlsx");
	/* 图片类型文件后缀 */
	public static final String[] IMAGE_TYPES = {"jpg", "png", "bmp", "jpeg", "gif", "tif"};
	/* 文档类型文件后缀 */
	public static final String[] OFFICE_TYPES = {"ppt", "docx", "pptx", "xls", "xlsx", "doc", "pdf", "pps", "txt"};
	/* 视频类型文件后缀 */
	public static final String[] VIDEO_TYPES = {"avi", "mp4", "mpeg", "mpg", "wmv", "flv", "3gp", "mov", "asf", "asx", "vob", "m2p", "dat", "rmvb", "rm", "mts", "mkv", "ts", "m4v"};
	/* 音频类型文件后缀 */
	public static final String[] AUDIO_TYPES = {"mp3", "wav", "wma", "m4a", "aac", "mp2"};	
	public final static String RESOURCE_SUFFIX_SWF = "swf";
	
	public final static String RESOURCE_TRANSPATH = "transfile";/*转码文件路径*/
	
	public final static String RESOURCE_TRANSPIC = "transpic";/*转码缩略图路径*/
	
	public final static int NOT_SPECIFIED_MODULE_TYPE_ID = -1;/*未指定模块id的默认值*/
	
	public final static String IMAGE_SRC_URL = "/resource/view/img_src/";//原图地址
	
	public final static String IMAGE_THUMB_URL = "/resource/view/img_thumb/";//缩略图地址
	
	public final static String IMAGE_URL = "/resource/view/img/"; //转码图地址
	
	public final static String DOC_URL = "/resource/view/doc/"; //文档读取地址
	
	public final static String PDF_URL = "/resource/view/pdf/"; //pdf读取地址
	
	public final static String MEDIA_URL = "/resource/view/media/"; //音视频读取地址
	
	public final static String CLASS_TWO_DIMENSION_PATH = "/class/dimension/"; //班级二维码地址 文件名为班级id.png
	
	public final static String SCHOOL_MOBILE_LOADING_PATH = "/school/mobile/load/"; //学校手机端加载页文件地址
	public final static String APP_ICON_PATH = "/app/icon/"; //应用图标路径
	
	public final static String COURSE_MEDIA_TYPE = "media";
	
	public final static String COURSE_RESOURCE_TYPE = "course_resource";
	
	public final static long COURSE_DOC_MAXSIZE = 31457280;//30M 课程文档最大值 (舍弃41943040)
	
	public final static long COURSE_IMAGE_MAXSIZE = 31457280;//30M 课程图片最大值
	
	public final static long COURSE_MEDIA_MAXSIZE = 209715200;//200M 课程音视频最大值
	
	public final static long GENERAL_MAXSIZE = 20971520;//20M 默认最大值
	
	public final static long COURSE_FILE_MAXSIZE = 52428800;//50M 课程文件最大值
	
	public final static String EXTRA_PATH_FOLDER = "extra";
	
	public final static String SCHOOL_SITE_PATH = "/site/"; //学校
	
	public final static float MIN_VIDEO_BITRATE = 3000f;
	public static enum FileType{
		LINK, //链接
		OFFICE, //文档
		AUDIO, // 音频
		VIDEO,  //视频
		IMAGE, //图片
		FILE, //文件
		UNKNOWN; //文档类型不明，
		
		
		public String toString(){
			return this.name().toLowerCase();
		}
		
		/**
		 * 是否有时长
		 * @param fileType
		 * @return
		 */
		public boolean hasDuration() {
			return this == AUDIO || this == VIDEO;
		}
		public static String getValidFileType(String fileType) {
			if(LINK.toString().equals(fileType)) {
				return LINK.toString();
			} else if(OFFICE.toString().equals(fileType)){
				return OFFICE.toString();
			} else if(AUDIO.toString().equals(fileType)){
				return AUDIO.toString();
			} else if(VIDEO.toString().equals(fileType)){
				return VIDEO.toString();
			} else if(IMAGE.toString().equals(fileType)){
				return IMAGE.toString();
			} else if(FILE.toString().equals(fileType)){
				return FILE.toString();
			} else if(UNKNOWN.toString().equals(fileType)){
				return UNKNOWN.toString();
			}
			else {
				return null;
			}
		}
	}
	
	/** 
	 * 根据当前文件路径解析不同大小文件的路径，提供参数： filePath,fileSizeType。
	 * 规则：源文件.后缀 ==》  源文件.大小类型.后缀
	 */
	public final static String DIFF_FILE_SIZE_PATH = 
			"${filePath.substring(0, filePath.lastIndexOf('.'))}.${fileSizeType}${filePath.substring(filePath.lastIndexOf('.'))}";
}
